package com.justnow.offer;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author justnow
 * Created on 2020-10-11
 * Description
 */
public class Wm01 {
    public String[] countString (String[] inputArray) {
        // write code here
        Set<String> set = new HashSet<>();
        List<String> res = new ArrayList<>();

        for (int i = 0; i < inputArray.length; i++) {
            if (set.contains(inputArray[i])) {
                res.add(inputArray[i]);
            } else {
                set.add(inputArray[i]);
            }
        }

        int length = res.size();
        String[] rs = new String[length];
        for (int i = 0; i < length; i++) {
            rs[i] = res.get(i);
        }
        return rs;
    }
}
